<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>温馨提示 - 给你最暖心的关怀</title>
    
    <style>
        body {
            margin: 0;
            padding: 0;
            font-family: '微软雅黑', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            overflow: hidden;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            -webkit-touch-callout: none;
            -webkit-tap-highlight-color: transparent;
        }

        .tip-container {
            position: fixed;
            width: clamp(200px, 25vw, 280px);
            height: clamp(50px, 8vh, 70px);
            border-radius: 15px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            font-size: clamp(12px, 3.5vw, 16px);
            font-weight: bold;
            color: #333;
            z-index: 1000;
            animation: fadeInScale 0.5s ease-out;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            -webkit-user-select: none;
            user-select: none;
            pointer-events: auto;
            padding: 8px;
            box-sizing: border-box;
        }

        @keyframes fadeInScale {
            0% {
                opacity: 0;
                transform: scale(0.8);
            }
            100% {
                opacity: 1;
                transform: scale(1);
            }
        }

        @keyframes fadeOutScale {
            0% {
                opacity: 1;
                transform: scale(1);
            }
            100% {
                opacity: 0;
                transform: scale(0.8);
            }
        }

        .fade-out {
            animation: fadeOutScale 0.5s ease-in forwards;
        }

        .control-panel {
            position: fixed;
            top: 10px;
            left: 10px;
            width: clamp(280px, 90vw, 350px);
            max-width: calc(100vw - 20px);
            background: rgba(255, 255, 255, 0.95);
            padding: clamp(12px, 3vw, 20px);
            border-radius: 15px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
            z-index: 2000;
            backdrop-filter: blur(10px);
            -webkit-user-select: none;
            user-select: none;
            box-sizing: border-box;
        }

        .control-panel h3 {
            margin: 0 0 12px 0;
            color: #333;
            font-size: clamp(16px, 4vw, 20px);
            text-align: center;
        }

        .control-panel button {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            padding: clamp(8px, 2.5vw, 12px) clamp(12px, 4vw, 20px);
            border-radius: 25px;
            cursor: pointer;
            font-size: clamp(12px, 3vw, 14px);
            margin: 3px;
            transition: transform 0.2s ease;
            min-height: 44px;
            min-width: 44px;
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
        }

        .control-panel button:hover,
        .control-panel button:active {
            transform: translateY(-2px);
        }

        .button-group {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 5px;
            margin-bottom: 10px;
        }

        .control-panel input {
            width: clamp(50px, 15vw, 70px);
            padding: clamp(6px, 1.5vw, 8px);
            border: 1px solid #ddd;
            border-radius: 8px;
            margin: 0 3px;
            font-size: clamp(12px, 3vw, 14px);
            text-align: center;
            min-height: 32px;
            box-sizing: border-box;
            -webkit-appearance: none;
            -moz-appearance: textfield;
        }

        .input-group {
            display: flex;
            align-items: center;
            justify-content: center;
            flex-wrap: wrap;
            gap: 5px;
            margin: 8px 0;
            font-size: clamp(12px, 3vw, 14px);
        }

        .stats {
            margin-top: 12px;
            font-size: clamp(10px, 2.5vw, 12px);
            color: #666;
            text-align: center;
            line-height: 1.4;
        }

        @media (max-width: 480px) {
            .control-panel {
                display: none;
            }
        }

        @media (orientation: landscape) and (max-height: 500px) {
            .control-panel {
                top: 5px;
                left: 5px;
                padding: 8px;
                max-height: calc(100vh - 10px);
                overflow-y: auto;
            }
            
            .control-panel h3 {
                font-size: 14px;
                margin-bottom: 5px;
            }
            
            .button-group {
                margin-bottom: 5px;
            }
            
            .stats {
                margin-top: 5px;
            }
        }
    </style>
</head>
<body>
    <div class="control-panel">
        <h3>🌟 温馨提示控制台</h3>
        <div class="button-group">
            <button onclick="startTips()">开始显示</button>
            <button onclick="stopTips()">停止显示</button>
            <button onclick="clearAllTips()">清除所有</button>
        </div>
        <div class="input-group">
            <div>数量: <input type="number" id="tipCount" value="300" min="1" max="500"></div>
            <div>间隔: <input type="number" id="interval" value="100" min="50" max="1000">ms</div>
        </div>
        <div class="stats">
            <div>当前显示: <span id="currentCount">0</span> 个</div>
            <div>总计创建: <span id="totalCount">0</span> 个</div>
        </div>
    </div>

    <script>
        const tips = [
            '多喝水哦，保持微笑呀', '每天都要元气满满', '记得吃水果', '保持好心情',
            '好好爱自己', '我想你了', '梦想成真', '期待下一次见面', '金榜题名', 
            '顺顺利利', '早点休息', '愿所有烦恼都消失', '别熬夜', '今天过得开心嘛', 
            '天冷了，多穿衣服', '记得按时吃饭', '工作再忙也要休息', '你是最棒的',
            '加油，你可以的', '今天也要开心哦', '记得给自己一个拥抱', '世界因你而美好'
        ];

        const bgColors = [
            'lightpink', 'skyblue', 'lightgreen', 'lavender', 'lightyellow', 'plum',
            'coral', 'bisque', 'aquamarine', 'mistyrose', 'honeydew', 'lavenderblush', 'oldlace'
        ];

        let currentTips = [];
        let totalCreated = 0;
        let isRunning = false;
        let intervalId = null;

        function getRandomInt(min, max) {
            return Math.floor(Math.random() * (max - min + 1)) + min;
        }

        function getRandomElement(array) {
            return array[Math.floor(Math.random() * array.length)];
        }

        function createTip() {
            const tipElement = document.createElement('div');
            tipElement.className = 'tip-container';
            
            const tip = getRandomElement(tips);
            const bgColor = getRandomElement(bgColors);
            
            tipElement.textContent = tip;
            tipElement.style.backgroundColor = bgColor;
            
            const tipWidth = Math.min(280, Math.max(200, window.innerWidth * 0.25));
            const tipHeight = Math.min(70, Math.max(50, window.innerHeight * 0.08));
            
            const safeMargin = 10;
            const maxX = window.innerWidth - tipWidth - safeMargin;
            const maxY = window.innerHeight - tipHeight - safeMargin;
            const x = getRandomInt(safeMargin, Math.max(safeMargin, maxX));
            const y = getRandomInt(safeMargin, Math.max(safeMargin, maxY));
            
            tipElement.style.left = x + 'px';
            tipElement.style.top = y + 'px';
            
            addTouchInteraction(tipElement);
            
            document.body.appendChild(tipElement);
            currentTips.push(tipElement);
            totalCreated++;
            
            updateStats();
            
            setTimeout(() => {
                closeTip(tipElement);
            }, 20000);
        }
        
        function addTouchInteraction(tipElement) {
            let isDragging = false;
            let startX, startY, initialX, initialY;
            
            // 鼠标/触摸开始事件
            function handleStart(e) {
                isDragging = true;
                
                // 获取触摸点或鼠标位置
                const clientX = e.touches ? e.touches[0].clientX : e.clientX;
                const clientY = e.touches ? e.touches[0].clientY : e.clientY;
                
                startX = clientX;
                startY = clientY;
                initialX = parseInt(tipElement.style.left) || 0;
                initialY = parseInt(tipElement.style.top) || 0;
                
                // 提高弹窗层级，确保在拖拽时显示在最前面
                tipElement.style.zIndex = '1001';
                
                // 阻止默认行为
                e.preventDefault();
            }
            
            // 鼠标/触摸移动事件
            function handleMove(e) {
                if (!isDragging) return;
                
                // 获取当前触摸点或鼠标位置
                const clientX = e.touches ? e.touches[0].clientX : e.clientX;
                const clientY = e.touches ? e.touches[0].clientY : e.clientY;
                
                // 计算移动距离
                const deltaX = clientX - startX;
                const deltaY = clientY - startY;
                
                // 计算新位置
                let newX = initialX + deltaX;
                let newY = initialY + deltaY;
                
                // 边界检查，确保弹窗不超出屏幕
                const tipRect = tipElement.getBoundingClientRect();
                const maxX = window.innerWidth - tipRect.width;
                const maxY = window.innerHeight - tipRect.height;
                
                newX = Math.max(0, Math.min(newX, maxX));
                newY = Math.max(0, Math.min(newY, maxY));
                
                // 应用新位置
                tipElement.style.left = newX + 'px';
                tipElement.style.top = newY + 'px';
                
                // 阻止默认行为
                e.preventDefault();
            }
            
            // 鼠标/触摸结束事件
            function handleEnd(e) {
                if (!isDragging) return;
                
                isDragging = false;
                
                // 恢复正常层级
                tipElement.style.zIndex = '1000';
                
                // 检查是否为点击（移动距离很小）
                const clientX = e.changedTouches ? e.changedTouches[0].clientX : e.clientX;
                const clientY = e.changedTouches ? e.changedTouches[0].clientY : e.clientY;
                
                const moveDistance = Math.sqrt(
                    Math.pow(clientX - startX, 2) + Math.pow(clientY - startY, 2)
                );
                
                // 如果移动距离小于10像素，认为是点击，关闭弹窗
                if (moveDistance < 10) {
                    closeTip(tipElement);
                }
            }
            
            // 添加事件监听器
            // 触摸事件（移动端）
            tipElement.addEventListener('touchstart', handleStart, { passive: false });
            tipElement.addEventListener('touchmove', handleMove, { passive: false });
            tipElement.addEventListener('touchend', handleEnd, { passive: false });
            
            // 鼠标事件（桌面端）
            tipElement.addEventListener('mousedown', handleStart);
            tipElement.addEventListener('mousemove', handleMove);
            tipElement.addEventListener('mouseup', handleEnd);
            
            // 防止拖拽时选中文本
            tipElement.addEventListener('selectstart', (e) => e.preventDefault());
        }

        function closeTip(tipElement) {
            if (tipElement && tipElement.parentNode) {
                tipElement.classList.add('fade-out');
                
                setTimeout(() => {
                    if (tipElement.parentNode) {
                        tipElement.parentNode.removeChild(tipElement);
                        
                        const index = currentTips.indexOf(tipElement);
                        if (index > -1) {
                            currentTips.splice(index, 1);
                        }
                        
                        updateStats();
                    }
                }, 500);
            }
        }

        function updateStats() {
            const currentCountElement = document.getElementById('current-count');
            const totalCountElement = document.getElementById('total-count');
            
            if (currentCountElement) {
                currentCountElement.textContent = currentTips.length;
            }
            if (totalCountElement) {
                totalCountElement.textContent = totalCreated;
            }
        }

        function startTips() {
            if (isRunning) return;
            
            isRunning = true;
            
            const count = parseInt(document.getElementById('tipCount').value) || 60;
            const interval = parseInt(document.getElementById('interval').value) || 100;
            
            let created = 0;
            
            intervalId = setInterval(() => {
                if (created >= count) {
                    clearInterval(intervalId);
                    isRunning = false;
                    return;
                }
                
                createTip();
                created++;
            }, interval);
        }

        function stopTips() {
            if (intervalId) {
                clearInterval(intervalId);
                intervalId = null;
            }
            isRunning = false;
        }

        function clearAllTips() {
            stopTips();
            
            currentTips.forEach(tip => {
                if (tip.parentNode) {
                    tip.parentNode.removeChild(tip);
                }
            });
            
            currentTips = [];
            updateStats();
        }

        window.addEventListener('load', () => {
            startTips();
            
            setTimeout(() => {
                stopTips();
                clearAllTips();
                
                setTimeout(() => {
                    window.close();
                }, 1000);
            }, 30000);
        });

        window.addEventListener('resize', function() {
            clearTimeout(window.resizeTimer);
            window.resizeTimer = setTimeout(function() {
                currentTips.forEach(function(tip) {
                    const currentLeft = parseInt(tip.style.left) || 0;
                    const currentTop = parseInt(tip.style.top) || 0;
                    const tipRect = tip.getBoundingClientRect();
                    
                    const safeMargin = 10;
                    const maxX = window.innerWidth - tipRect.width - safeMargin;
                    const maxY = window.innerHeight - tipRect.height - safeMargin;
                    
                    let newLeft = Math.max(safeMargin, Math.min(currentLeft, maxX));
                    let newTop = Math.max(safeMargin, Math.min(currentTop, maxY));
                    
                    tip.style.left = newLeft + 'px';
                    tip.style.top = newTop + 'px';
                });
            }, 100);
        });
    </script>
</body>
</html>